package com.bzyd.ss.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bzyd.ss.model.entity.UserEntity;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper extends BaseMapper<UserEntity> {

    // 根据用户id查询角色名称，t_role.role_name
    @Select("select role_name from t_role where id in (select role_id from t_user_role where user_id = #{userId})")
    List<String> selectRolesByUserId(Integer userId);

    // 根据用户id查询权限描述，t_resource.res
    @Select("select res from t_resource where id in (select res_id from t_role_res where role_id in (select role_id from t_user_role where user_id = #{userId}))")
    List<String> selectResourcesByUserId(Integer userId);
}
